package com.inmaytide.website.mapper.deploy;

import com.inmaytide.website.domain.entities.deploy.DeployProject;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface DeployProjectMapper extends Mapper<DeployProject> {

    @Select({
            "select * from deploy_project order by sort"
    })
    @Results({
            @Result(column = "in_use", property = "inUse")
    })
    public List<DeployProject> findList();

    @Select({
            "select * from deploy_project where id = #{id}"
    })
    @Results({
            @Result(column = "in_use", property = "inUse")
    })
    public DeployProject findOne(@Param("id") Long id);

    @Select({
            "select ifnull(max(sort), 0) maxsort from deploy_project"
    })
    public long getMaxSort();

    @Select({
            "select * from deploy_project where in_use = 1 order by sort"
    })
    @Results({
            @Result(column = "in_use", property = "inUse")
    })
    List<DeployProject> findProjectsInUse();
}